class Solution(object):
    def compress(self, chars):
        """
        :type chars: List[str]
        :rtype: int
        """
        n = len(chars)
        index1 = 1
        index2 = 1
        last_value = chars[0]
        count = 1
        while index1 < n:
            if chars[index1] == last_value:
                count += 1
            else:
                if count > 1:
                    count = str(count)
                    for k in range(len(count)):
                        chars[index2] = count[k]
                        index2 += 1
                    count = 1
                last_value = chars[index1]
                chars[index2] = chars[index1]
                index2 += 1
            index1 += 1
        if count > 1:
            count = str(count)
            for k in range(len(count)):
                chars[index2] = count[k]
                index2 += 1
        chars = chars[:index2]
        return len(chars)


data = Solution()
# chars = ["a", "a", "b", "b", "c", "c", "c"]
# print(data.compress(chars))
# chars = ["a","b","b","b","b","b","b","b","b","b","b","b","b"]
# print(data.compress(chars))
chars = ["a"]
print(data.compress(chars))